package com.ruoyi.web.controller.tool;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.utils.HttpClientSslUtils;
import com.ruoyi.stock.domain.StockDfcf;

public class Test {

    public static void main(String[] args) throws Exception {
        String url="http://38.push2.eastmoney.com/api/qt/clist/get?pn=1&pz=20&po=1&np=1&fltt=2&invt=2&dect=1&fid=f3&fs=m:1+t:2,m:1+t:23";
        String[] url1=url.split("&");
        JSONObject wxJson = JSON.parseObject(HttpClientSslUtils.doGet(url));
        JSONObject  obj=   JSON.parseObject(wxJson.get("data").toString());
        JSONArray obj1=  obj.getJSONArray("diff");
        StockDfcf stockDfcf=new StockDfcf();
        System.out.println(obj1.get(1).toString());
        stockDfcf.setSecurityName(JSON.parseObject(obj1.get(0).toString()).get("f14").toString());
        stockDfcf.setSecurityCode(JSON.parseObject(obj1.get(0).toString()).get("f12").toString());
        stockDfcf.setLastPrice((JSON.parseObject(obj1.get(0).toString()).get("f2").toString()));
        stockDfcf.setLatestIncrease((JSON.parseObject(obj1.get(0).toString()).get("f3").toString()));
        stockDfcf.setLatestChangedMoney((JSON.parseObject(obj1.get(0).toString()).get("f4").toString()));
       //  stockDfcf.setTurnover();
        //成交量，成交额
        stockDfcf.setAmplitude((JSON.parseObject(obj1.get(0).toString()).get("f7").toString()));
        stockDfcf.setHighest((JSON.parseObject(obj1.get(0).toString()).get("f15").toString()));
        stockDfcf.setHighest((JSON.parseObject(obj1.get(0).toString()).get("f15").toString()));
        stockDfcf.setLowest((JSON.parseObject(obj1.get(0).toString()).get("f16").toString()));
        stockDfcf.setTodayOpen((JSON.parseObject(obj1.get(0).toString()).get("f17").toString()));
        stockDfcf.setYesterdayClose((JSON.parseObject(obj1.get(0).toString()).get("f18").toString()));
        //换手
        //stockDfcf.setHighest();
       // stockDfcf.setCirculationMarketValue(JSON.parseObject(obj1.get(0).toString()).get("f2").toString());

//        List<StockBaseField> list=new ArrayList<StockBaseField>();
//        for(int i=0;i<obj.size();i++){
//            JSONArray obj1=  obj.getJSONArray("diff");
//            StockBaseField stockBaseField=new StockInquery();
//            stockBaseField.setSecurityName(JSON.parseObject(obj1.get(0).toString()).get("f14").toString());
//            stockBaseField.setSecurityCode(JSON.parseObject(obj1.get(0).toString()).get("f12").toString());
//            stockBaseField.setLastPrice(new BigDecimal(JSON.parseObject(obj1.get(0).toString()).get("f2").toString()));
//            stockBaseField.setLatestIncrease(new BigDecimal(JSON.parseObject(obj1.get(0).toString()).get("f25").toString()));
//            stockBaseField.setCirculationMarketValue(new BigDecimal(JSON.parseObject(obj1.get(0).toString()).get("f2").toString()));
//           // stockInquery.set(JSON.parseObject(obj1.get(0).toString()).get("f12").toString());
//        }
       // System.out.println(list);
    }
}
